<!doctype html>



  


<html class="theme-next mist use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Jhin" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.2" />






<meta name="description" content="ONex B2B2C 二次开发之模板机制特点1、所见即所得的可视化模板板块编译机制2、将布局、区块、边框、数据，真正细分化
名词挂件区域（widgets）挂件区域用于在某个页面预留挂件（widget）可挂入的区域。也可以理解为“插槽”，“坑”。每个挂件区域可以挂入多个挂件。">
<meta property="og:type" content="article">
<meta property="og:title" content="ONex B2B2C 二次开发 模板机制">
<meta property="og:url" content="http://jhin.oschina.io/ShopEX/2016-10-21-08.ONex B2B2C 二次开发之模板机制.html">
<meta property="og:site_name" content="Jhin">
<meta property="og:description" content="ONex B2B2C 二次开发之模板机制特点1、所见即所得的可视化模板板块编译机制2、将布局、区块、边框、数据，真正细分化
名词挂件区域（widgets）挂件区域用于在某个页面预留挂件（widget）可挂入的区域。也可以理解为“插槽”，“坑”。每个挂件区域可以挂入多个挂件。">
<meta property="og:updated_time" content="2016-12-22T01:45:37.730Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="ONex B2B2C 二次开发 模板机制">
<meta name="twitter:description" content="ONex B2B2C 二次开发之模板机制特点1、所见即所得的可视化模板板块编译机制2、将布局、区块、边框、数据，真正细分化
名词挂件区域（widgets）挂件区域用于在某个页面预留挂件（widget）可挂入的区域。也可以理解为“插槽”，“坑”。每个挂件区域可以挂入多个挂件。">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Mist',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    }
  };
</script>




  <link rel="canonical" href="http://jhin.oschina.io/ShopEX/2016-10-21-08.ONex B2B2C 二次开发之模板机制.html"/>


  <title> ONex B2B2C 二次开发 模板机制 | Jhin </title>
</head>

<body itemscope itemtype="//schema.org/WebPage" lang="zh-Hans">

  










  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="//schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta custom-logo">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">Jhin</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">Jhin(ijhin@sina.com)</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-thinkphp">
          <a href="/categories/ThinkPHP-DOC" rel="section">
            
            ThinkPHP
          </a>
        </li>
      
        
        <li class="menu-item menu-item-mysql">
          <a href="/categories/MySQL" rel="section">
            
            MySQL
          </a>
        </li>
      
        
        <li class="menu-item menu-item-php">
          <a href="/categories/PHP" rel="section">
            
            PHP
          </a>
        </li>
      
        
        <li class="menu-item menu-item-linux">
          <a href="/categories/Linux" rel="section">
            
            Linux
          </a>
        </li>
      
        
        <li class="menu-item menu-item-nginx">
          <a href="/categories/Nginx" rel="section">
            
            Nginx
          </a>
        </li>
      
        
        <li class="menu-item menu-item-html">
          <a href="/categories/HTML" rel="section">
            
            HTML5
          </a>
        </li>
      
        
        <li class="menu-item menu-item-javascript">
          <a href="/categories/JavaScript" rel="section">
            
            JavaScript
          </a>
        </li>
      
        
        <li class="menu-item menu-item-onex">
          <a href="/categories/ONEX" rel="section">
            
            ONEX
          </a>
        </li>
      
        
        <li class="menu-item menu-item-yii">
          <a href="/categories/Yii2" rel="section">
            
            Yii2
          </a>
        </li>
      
        
        <li class="menu-item menu-item-shopex">
          <a href="/categories/ShopEX" rel="section">
            
            ShopEX
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="//schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                ONex B2B2C 二次开发 模板机制
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-10-21T14:51:55+08:00" content="2016-10-21">
              2016-10-21
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/ShopEX/" itemprop="url" rel="index">
                    <span itemprop="name">ShopEX</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
          

          

          
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="ONex-B2B2C-二次开发之模板机制"><a href="#ONex-B2B2C-二次开发之模板机制" class="headerlink" title="ONex B2B2C 二次开发之模板机制"></a>ONex B2B2C 二次开发之模板机制</h2><h3 id="特点"><a href="#特点" class="headerlink" title="特点"></a>特点</h3><p>1、所见即所得的可视化模板板块编译机制<br>2、将布局、区块、边框、数据，真正细分化</p>
<h3 id="名词"><a href="#名词" class="headerlink" title="名词"></a>名词</h3><h4 id="挂件区域（widgets）"><a href="#挂件区域（widgets）" class="headerlink" title="挂件区域（widgets）"></a>挂件区域（widgets）</h4><p>挂件区域用于在某个页面预留挂件（widget）可挂入的区域。也可以理解为“插槽”，“坑”。每个挂件区域可以挂入多个挂件。</p>
<a id="more"></a>
<h4 id="挂件（widget）"><a href="#挂件（widget）" class="headerlink" title="挂件（widget）"></a>挂件（widget）</h4><p>挂件是ShopEx（ecstore）模板机制中的一个重要角色，它能根据条件从后端取得数据然后根据“模板级挂件”来包装成一个小版块。</p>
<p>例如一个“商品版块挂件”，它要先由后端语言（PHP）来组织数据，然后返回到“模板级挂件”。组织数据的条件将会独立出一个可配置的页面。</p>
<h4 id="系统级区域（main）"><a href="#系统级区域（main）" class="headerlink" title="系统级区域（main）"></a>系统级区域（main）</h4><p>系统级区域用于输出系统的核心交互流程。这些区域的html、JavaScript是不能再模板包中直接定义的，模板包唯一能影响到这些系统级区域的是 css 样式定义，因为模板包的样式表是在系统级样式之后加载的。</p>
<h4 id="默认模板页（default-html）"><a href="#默认模板页（default-html）" class="headerlink" title="默认模板页（default.html）"></a>默认模板页（default.html）</h4><p>默认模板页是在模板包中，未定义某个页面的布局时，默认调用的页面布局。例如你的模板包中只包含了两个页面的定义：首页、默认页，那么其他未定义的页面在访问时将优先使用默认模板页，直到你单独定义它为止。</p>
<h3 id="创建模板包"><a href="#创建模板包" class="headerlink" title="创建模板包"></a>创建模板包</h3><h4 id="标准模板包"><a href="#标准模板包" class="headerlink" title="标准模板包"></a>标准模板包</h4><p>1、创建模板包的文件夹名称<br>    例如：tfmall<br>    存放位置：/public/themes/tfmall</p>
<p>2、创建模板包中的必要文件</p>
<pre><code>theme.xml 此文件用来描述模板包的基本信息，以及模板可能包含的挂件。还用于模板的备份导出，和导入操作中的模板数据交换。例如：

<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div><div class="line">112</div><div class="line">113</div><div class="line">114</div><div class="line">115</div><div class="line">116</div><div class="line">117</div><div class="line">118</div><div class="line">119</div></pre></td><td class="code"><pre><div class="line">	<span class="php"><span class="meta">&lt;?</span>xml version=<span class="string">"1.0"</span> encoding=<span class="string">"UTF-8"</span> <span class="meta">?&gt;</span></span></div><div class="line">		<span class="tag">&lt;<span class="name">theme</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">name</span>&gt;</span>TF<span class="tag">&lt;/<span class="name">name</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">platform</span>&gt;</span>pc<span class="tag">&lt;/<span class="name">platform</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">id</span>&gt;</span>tfmall<span class="tag">&lt;/<span class="name">id</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">version</span>&gt;</span>tfmall<span class="tag">&lt;/<span class="name">version</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">info</span>&gt;</span>TF<span class="tag">&lt;/<span class="name">info</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">author</span>&gt;</span>ijhin@sina.com<span class="tag">&lt;/<span class="name">author</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">site</span>&gt;</span>http://ijhin.com<span class="tag">&lt;/<span class="name">site</span>&gt;</span></div><div class="line"></div><div class="line">		    <span class="tag">&lt;<span class="name">borders</span>&gt;</span><span class="tag">&lt;<span class="name">set</span> <span class="attr">key</span>=<span class="string">"a"</span> <span class="attr">tpl</span>=<span class="string">"a"</span> /&gt;</span><span class="tag">&lt;/<span class="name">borders</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">views</span>&gt;</span><span class="tag">&lt;<span class="name">set</span> <span class="attr">app</span>=<span class="string">"a"</span> <span class="attr">view</span>=<span class="string">"a"</span> <span class="attr">tpl</span>=<span class="string">"a"</span> /&gt;</span><span class="tag">&lt;/<span class="name">views</span>&gt;</span></div><div class="line">		    <span class="tag">&lt;<span class="name">config</span>&gt;</span><span class="tag">&lt;<span class="name">set</span> <span class="attr">key</span>=<span class="string">"a"</span> <span class="attr">value</span>=<span class="string">"a"</span> <span class="attr">label</span>=<span class="string">"a"</span> /&gt;</span><span class="tag">&lt;/<span class="name">config</span>&gt;</span></div><div class="line">    		<span class="tag">&lt;<span class="name">widgets</span>&gt;</span><span class="tag">&lt;/<span class="name">widgets</span>&gt;</span></div><div class="line">		<span class="tag">&lt;/<span class="name">theme</span>&gt;</span></div><div class="line">	```	</div><div class="line"></div><div class="line">	|- XML节点说明</div><div class="line">	||- name	模板包的名称，将会出现在管理后台模板列表中</div><div class="line">	||- platform	所用平台</div><div class="line">	||- id		首次由开发人员定义，应与模板包名称保持一致（全英文）</div><div class="line">	||- version	模板包的版本信息</div><div class="line">	||- info	模板包简介</div><div class="line">	||- author	模板包作者</div><div class="line">	||- site	模板包作者网址</div><div class="line">	||- update_url	升级地址，暂未启用</div><div class="line">	||- borders	模板包包含的边框定义描述</div><div class="line">	||- widgets 模板挂件描述。系统会在模板可视化编辑添加挂件后向widgets序列化挂件描述</div><div class="line"></div><div class="line">3、每个模板页将用到的公共页面引用 (header.html、footer.html) </div><div class="line"></div><div class="line">例如:(header.html)</div><div class="line"></div><div class="line">``` HTML</div><div class="line"></div><div class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">&#123;header</span> <span class="attr">app</span>=<span class="string">topc&#125;</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">"stylesheet"</span> <span class="attr">href</span>=<span class="string">"images/index.css"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"></div><div class="line">  <span class="tag">&lt;<span class="name">body</span> <span class="attr">class</span>=<span class="string">"is-index"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">&#123;require</span> <span class="attr">file</span>=<span class="string">"block/header.html"</span>&#125;&gt;</span></div><div class="line">    <span class="comment">&lt;!-- 主内容区 --&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"seaview"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wrap-lg"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"row cover-content"</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"col-lg-3 box cover-silder-gg"</span>&gt;</span></div><div class="line">              <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"banners"</span>&#125;&gt;</span></div><div class="line">            <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">          <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"full-slider"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"main_focus"</span>&#125;&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"main"</span> <span class="attr">class</span>=<span class="string">"main index"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wrap-lg"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"activity"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"hot_brand"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"coupon"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"floor_index_01"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module-bd"</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"ad_01"</span>&#125;&gt;</span></div><div class="line">          <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"floor_index_02"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module-bd"</span>&gt;</span></div><div class="line">            <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"ad_02"</span>&#125;&gt;</span></div><div class="line">          <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"floor_index_03"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"relation_brand_01"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"floor_index_04"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"relation_brand_02"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"floor_index_05"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"ad_group"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"module"</span>&gt;</span></div><div class="line">          <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"goods_recommond"</span>&#125;&gt;</span></div><div class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">&#123;require</span> <span class="attr">file</span>=<span class="string">"block/footer.html"</span>&#125;&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="undefined"></span></div><div class="line">  $(function()&#123;</div><div class="line">    $("img.imglazyload").lazyload(&#123;</div><div class="line">         effect : "fadeIn"</div><div class="line">     &#125;);</div><div class="line">  &#125;);</div><div class="line">  <span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
</code></pre><p>例如：（block/header.html）</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"topbar"</span> <span class="attr">class</span>=<span class="string">"topbar"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wrap-lg"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"topbar-left"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"tbl"</span>&#125;&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"topbar-right"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"tbr"</span>&#125;&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="comment">&lt;!-- 头部信息栏 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"header"</span> <span class="attr">class</span>=<span class="string">"header"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wrap-lg"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"row"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"col-4"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"hl"</span>&#125;&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"col-12"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"hm"</span>&#125;&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"col-lg-3"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"hr"</span>&#125;&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"></div><div class="line"><span class="comment">&lt;!-- 页面导航栏 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">id</span>=<span class="string">"nav"</span> <span class="attr">class</span>=<span class="string">"nav"</span>&gt;</span></div><div class="line">  <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"wrap-lg"</span>&gt;</span></div><div class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"row"</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"col-lg-3 nav-left"</span>&gt;</span><span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"navl"</span> <span class="attr">ttl</span>=<span class="string">20&#125;</span>&gt;</span><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">      <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"offset-lg-3 nav-main"</span>&gt;</span></div><div class="line">        <span class="tag">&lt;<span class="name">&#123;widgets</span> <span class="attr">id</span>=<span class="string">"navm"</span> <span class="attr">isCache</span>=<span class="string">"false"</span>&#125;&gt;</span></div><div class="line">      <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">  <span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="undefined"></span></div><div class="line">  $(function()&#123;</div><div class="line">    $("img.imglazyload").lazyload(&#123;</div><div class="line">         effect : "fadeIn"</div><div class="line">     &#125;);</div><div class="line">  &#125;);</div><div class="line"><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div></pre></td></tr></table></figure>
<p>标签说明：</p>
<p>目录绝对路径</p>
<pre><code>/webroot/public/themes/lucymall/index.html
</code></pre><p>首先看到的第一个标签是 </p>
<pre><code>&lt;{header app=topc}&gt;

作用：
app=topc 指的是/webroot/app/topc
加载基础模板样式，引用位置 /webroot/app/topc/view/common/header.html
</code></pre><p>在header.html 内有以下标签：</p>
<pre><code>&lt;{script src=&quot;lib/lab.js&quot; app=&quot;site&quot;}&gt;

作用： 
app=&quot;site&quot; 指的是 /webroot/public/app/site
加载基础的javascript文件，引用位置 
/webroot/public/app/site/statics/scripts/lib/lab.js

&lt;{css src=&quot;layout.css&quot; app=&quot;topc&quot;}&gt;

作用： 
app=&quot;topc&quot; 指的是 /webroot/public/app/topc
加载基础的javascript文件，引用位置 
/webroot/public/app/topc/statics/stylesheets/layout.css
</code></pre><p>返回 index.html 文件内，接着往下看：</p>
<pre><code>&lt;{require file=&quot;block/header.html&quot;}&gt;

作用：引用公共 header.html
文件位置：
/webroot/public/themes/luckymall/block/header.html

&lt;{widgets id=&quot;banners&quot;}&gt;

作用：
设置 id 为 banners 的 挂件域id，唯一值。更新名称后，在模板-&gt;更多-&gt;维护或者在可视化界面刷新。
</code></pre><p>4、默认模板页（default.html）</p>
<p>类似上面的（index.html）,不做赘述。</p>
<p>5、边框 （borders）<br>应该建立 borders文件夹，来存放一个个的边框 html，html属性应统一用双引号，防止出现模板解析异常例如：borders/border1.html</p>
<figure class="highlight html"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"border1 &lt;&#123;$widgets_classname&#125;&gt;"</span> <span class="attr">id</span>=<span class="string">"&lt;&#123;$widgets_id&#125;&gt;"</span>&gt;</span></div><div class="line"><span class="comment">&lt;!--将输出被包装挂件板块在后台定义的边框className、id--&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">h3</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">&#123;$title&#125;</span>&gt;</span><span class="comment">&lt;!--将输出被包装挂件板块在后台定义的标题--&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">h3</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">&#123;$body&#125;</span>&gt;</span><span class="comment">&lt;!--将输出被包装挂件板块内容--&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div></pre></td></tr></table></figure>
<p>6、资源文件夹（images）<br>存放模板资源文件，例如css\js\图片、swf</p>
<p>7、一张模板效果图（preview.jpg）<br>模板效果图是一张直观的模板效果图片（120＊160 px）,可以在管理后台模板列表看到它以区分模板。</p>
<h3 id="模板包的首次加载"><a href="#模板包的首次加载" class="headerlink" title="模板包的首次加载"></a>模板包的首次加载</h3><h4 id="模板包的首次加载-1"><a href="#模板包的首次加载-1" class="headerlink" title="模板包的首次加载"></a>模板包的首次加载</h4><p>当首次构建好基础模板包。此刻应将模板文件夹复制到网店模板目录<br>既：b2b2c/public/themes下<br>这时你的模板列表中将出现此模板的记录，<br>首次的模板加载应通过文件夹复制的方式放置到指定位置（b2b2c/public/themes/）下。不应该直接将其以压缩包的形式通过模板上传加载。</p>
<h4 id="完善模板包"><a href="#完善模板包" class="headerlink" title="完善模板包"></a>完善模板包</h4><p>上文提到我们仅构建了标准的模板包。下面我们应为某些页面添加更丰富的布局页面文件：</p>
<p>添加页面布局文件时<br>需要输入名称、文件名、和页面源码<br>名称可以理解为对文件的备注，文件名会自动追加.html后缀,页面源码会模板复制默认布局页源码。<br>在此可以修改html源码页可以只输入名称和文件名先生成html文件到模板包。统一用其他工具编辑页面源码。</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/ShopEX/2016-10-21-07.ONex B2B2C 二次开发之写库操作.html" rel="next" title="ONex B2B2C 二次开发 写库操作">
                <i class="fa fa-chevron-left"></i> ONex B2B2C 二次开发 写库操作
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/ShopEX/2016-10-21-11.ONex B2B2C 二次开发之增加单页.html" rel="prev" title="ONex B2B2C 二次开发 增加单页">
                ONex B2B2C 二次开发 增加单页 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="//schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/avatar.gif"
               alt="Jhin" />
          <p class="site-author-name" itemprop="name">Jhin</p>
          <p class="site-description motion-element" itemprop="description">Jhin 开发文档小结</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">22</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">分类</span>
              
            </div>
          

          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#ONex-B2B2C-二次开发之模板机制"><span class="nav-number">1.</span> <span class="nav-text">ONex B2B2C 二次开发之模板机制</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#特点"><span class="nav-number">1.1.</span> <span class="nav-text">特点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#名词"><span class="nav-number">1.2.</span> <span class="nav-text">名词</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#挂件区域（widgets）"><span class="nav-number">1.2.1.</span> <span class="nav-text">挂件区域（widgets）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#挂件（widget）"><span class="nav-number">1.2.2.</span> <span class="nav-text">挂件（widget）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#系统级区域（main）"><span class="nav-number">1.2.3.</span> <span class="nav-text">系统级区域（main）</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#默认模板页（default-html）"><span class="nav-number">1.2.4.</span> <span class="nav-text">默认模板页（default.html）</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#创建模板包"><span class="nav-number">1.3.</span> <span class="nav-text">创建模板包</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#标准模板包"><span class="nav-number">1.3.1.</span> <span class="nav-text">标准模板包</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#模板包的首次加载"><span class="nav-number">1.4.</span> <span class="nav-text">模板包的首次加载</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#模板包的首次加载-1"><span class="nav-number">1.4.1.</span> <span class="nav-text">模板包的首次加载</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#完善模板包"><span class="nav-number">1.4.2.</span> <span class="nav-text">完善模板包</span></a></li></ol></li></ol></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Jhin</span>
</div>

<div class="powered-by">
  由 <a class="theme-link" href="/">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="/">
    NexT.Mist
  </a>
</div>

        

        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.2"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.2"></script>



  



  




  
  

  

  

  

  


</body>
</html>
